var app = getApp();

Page({
    data: {
        luntext: [ "全部", "待参加", "审核中", "已验票", "退票" ],
        activeIndex: 0,
        page: 1,
        my_tickets: []
    },
    onLoad: function(a) {
        wx.hideShareMenu(), app.setNavigationBarColor(this);
        var t = this, e = wx.getStorageSync("db_tab"), n = app.contains(e, "../piaoquan/piaoquan");
        if (console.log(n), 0 != n && (e[n].color = "selsects", e[n].img = e[n].icon1, console.log(e)), 
        t.setData({
            yes: n,
            db_tab: e
        }), t.setData({
            db_tab: e
        }), null == a.activeIndex) ; else {
            var i = a.activeIndex;
            t.setData({
                activeIndex: i
            });
        }
        t.refresh();
    },
    refresh: function(a) {
        var t, n = this, i = n.data.page, e = n.data.activeIndex, s = wx.getStorageSync("userInfo").id;
        0 == e ? t = "" : 1 == e ? t = "2" : 2 == e ? t = "1" : 3 == e ? t = "3" : 4 == e && (t = "5"), 
        console.log(t);
        var o = n.data.my_tickets;
        app.util.request({
            url: "entry/wxapp/MyTickets",
            cachetime: "0",
            data: {
                user_id: s,
                state: t,
                page: i
            },
            success: function(a) {
                if (console.log(a), 0 < a.data.length) {
                    n.setData({
                        page: i + 1,
                        many: !0
                    }), o = o.concat(a.data);
                    var t = app.today_time();
                    for (var e in console.log(t), a.data) a.data[e].end_time = app.ormatDate(a.data[e].end_time), 
                    t > a.data[e].end_time ? (a.data[e].state = "失效", a.data[e].states = 2) : a.data[e].end_time, 
                    a.data[e].end = a.data[e].end_time.slice(0, 16), 1 == a.data[e].hd_place ? a.data[e].hd_place = "线上活动" : a.data[e].hd_place = "线下活动";
                    n.setData({
                        my_tickets: o
                    });
                } else n.setData({
                    page: i,
                    many: !1
                });
            }
        });
    },
    piaoinfo: function(a) {
        console.log(a);
        var t = a.currentTarget.dataset.id, e = a.currentTarget.dataset.state, n = a.currentTarget.dataset.states, i = a.currentTarget.dataset.fu_id;
        wx.navigateTo({
            url: "../piaoquaninfo/piaoquaninfo?id=" + t + "&state=" + e + "&states=" + n + "&fu_id=" + i
        });
    },
    tabClick: function(a) {
        this.setData({
            activeIndex: a.currentTarget.id,
            page: 1,
            my_tickets: []
        }), this.refresh();
    },
    wode: function() {
        var a = this.data.db_tab;
        wx.reLaunch({
            url: a[3].src
        });
    },
    fabu: function() {
        wx.reLaunch({
            url: "../fabu/fabu"
        });
    },
    index: function() {
        var a = this.data.db_tab;
        wx.reLaunch({
            url: a[0].src
        });
    },
    classifination: function(a) {
        var t = this.data.db_tab;
        wx.reLaunch({
            url: t[1].src
        });
    },
    mine_activity: function(a) {
        var t = this.data.db_tab;
        wx.reLaunch({
            url: t[2].src
        });
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {
        this.setData({
            page: 1,
            my_tickets: []
        }), this.refresh(), wx.stopPullDownRefresh();
    },
    onReachBottom: function() {
        console.log("上拉触底"), this.refresh();
    }
});